#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

struct HighSpeedContent
{
    bool detected=false,ignoreAble=false;
    double left,right;
    HighSpeedContent(double left,double right)
     :left(left),right(right){}
};


const int N=1e5;
long long t,n,m,L,V;
long long d[N],v[N],a[N],p[N],ans1,ans2;
bool enabled[N];
vector < HighSpeedContent > contents;
vector < int > ignores;

bool check(int organizeCode){//O(NM)
    int res=0;
    for(int i=0;i<contents.size();++i){
        if(!contents[i].detected){
            continue;
        }
        if(contents[i].ignoreAble){
            ++res;
            continue;
        }
        for(int j=0;j<m;++j){
            if(!enabled[j])continue;
            // cout<<contents[i].left<<"->"<<contents[i].right<<"["<<p[j]<<"]\n";
            if(contents[i].left<=p[j]&&contents[i].right>=p[j]){
                ++res;
                break;
            }
        }
        if(contents[i].left<=p[organizeCode]&&contents[i].right>=p[organizeCode]){
            ignores.push_back(i);
        }
    }
    // cout<<"==========\n";
    return res==ans1;
}

double accelSpeedFunc(int v,int aim_v,int a){
    return (aim_v*aim_v-v*v)/(2.0*a);
}

bool needAtleastOne;

int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	iostream::sync_with_stdio(false);
	cin.tie(0);

    cin>>t;

    while (t--)
    {
        contents.clear();
        memset(enabled,0,sizeof(enabled));
        ans1=0,ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;++i){//O(N)
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]==0){
                if(v[i]>V){
                    contents.push_back(HighSpeedContent(
                        d[i],
                        L
                    ));
                }
                continue;
            }else if(a[i]>0){
                contents.push_back(HighSpeedContent(
                    accelSpeedFunc(v[i],V,a[i])+d[i],
                    L
                ));
            }else{
                if(v[i]<=V){
                    continue;
                }
                contents.push_back(HighSpeedContent(
                    d[i],
                    accelSpeedFunc(v[i],V,a[i])+d[i]
                ));
            }
        }
        for(int i=0;i<m;++i){//O(NM)
            cin>>p[i];
            enabled[i]=true;
            for(int j=0;j<contents.size();++j){
                if(contents[j].left<=p[i]&&contents[j].right>=p[i]&&!contents[j].detected){
                    contents[j].detected=true;
                    ++ans1;
                }
            }
        }

        // for(int i=0;i<contents.size();++i){
        //      cout<<contents[i].left<<"->"<<contents[i].right<<endl;
        // }

        for(int i=0;i<m;++i){//O(NM2)
            ignores.clear();
            enabled[i]=false;
            if(check(i)){
                // cout<<"ACCEPTED\n\n";
                ++ans2;
            }else{
                enabled[i]=true;
                for(int j=0;j<ignores.size();++j){
                    contents[ignores[j]].ignoreAble=true;
                    // cout<<"ignored:"<<contents[ignores[j]].left<<"->"<<contents[ignores[j]].right<<endl;
                }
            }
        }

        cout<<ans1<<" "<<ans2<<endl;
    }
    
    

	return 0;
}